<template>
  <div>
    <div style="margin-bottom: 10px">
      标题：我是标题
    </div>
    <div style="margin-bottom: 10px">
      单位：我是单位
    </div>
    <div>
      <div class="coordinates">
        <div>横坐标：</div>
        <div v-for="(item,index) in list">
          <input type="text" class="coordinates-input" v-model="item.value">
        </div>
        <img src="../../../assets/blankadd.png" alt="" class="add" @click="add">
      </div>
      <div class="coordinates" style="margin-top: 20px;">
        <div>纵坐标：</div>
        <div v-for="(item,index) in valueList">
          <input type="text" class="coordinates-input" v-model="item.value">
        </div>
      </div>
    </div>
    <div style="margin: 10px auto;text-align: center">
      <el-button @click="cancel">取消</el-button>
      <el-button type="danger" @click="save">保存</el-button>
    </div>
  </div>
</template>

<script>
  export default {
    name: "add",
    data() {
      return {
        list: [],
        valueList:[]
      }
    },
    methods: {
      // 点击添加
      add() {
        let that = this;
        that.list.push({value: ""});
        that.valueList.push({value: ""});
        console.log(that.list);
      },
      // 保存
      save(){
        this.$emit("saveFn",false);
      },
      // 取消
      cancel(){
        this.$emit("cencelFn",false);
      },
    }
  }
</script>

<style scoped>
  .coordinates {
    display: flex;
    align-items: center;
  }

  .coordinates-input {
    border: 1px solid #aaa;
    width: 20px;
    height: 25px;
    border-radius: 5px;
    margin-right: 5px;
  }

  .add {
    width: 20px;
    height: 20px;
  }
</style>
